﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace UserAuthen.Migrations
{
    /// <inheritdoc />
    public partial class v11 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Registration_Exam_ExamID1",
                table: "Registration");

            migrationBuilder.DropTable(
                name: "User");

            migrationBuilder.DropIndex(
                name: "IX_Registration_ExamID1",
                table: "Registration");

            migrationBuilder.DropColumn(
                name: "ExamID1",
                table: "Registration");

            migrationBuilder.AlterColumn<Guid>(
                name: "ExamID",
                table: "Registration",
                type: "TEXT",
                nullable: false,
                oldClrType: typeof(int),
                oldType: "INTEGER");

            migrationBuilder.AlterColumn<Guid>(
                name: "ID",
                table: "Registration",
                type: "TEXT",
                nullable: false,
                oldClrType: typeof(int),
                oldType: "INTEGER")
                .OldAnnotation("Sqlite:Autoincrement", true);

            migrationBuilder.AlterColumn<Guid>(
                name: "Registration2ID",
                table: "ExamRoomAllocation",
                type: "TEXT",
                nullable: false,
                oldClrType: typeof(int),
                oldType: "INTEGER");

            migrationBuilder.AlterColumn<Guid>(
                name: "Registration1ID",
                table: "ExamRoomAllocation",
                type: "TEXT",
                nullable: false,
                oldClrType: typeof(int),
                oldType: "INTEGER");

            migrationBuilder.CreateIndex(
                name: "IX_Registration_ExamID",
                table: "Registration",
                column: "ExamID");

            migrationBuilder.AddForeignKey(
                name: "FK_Registration_Exam_ExamID",
                table: "Registration",
                column: "ExamID",
                principalTable: "Exam",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Registration_Exam_ExamID",
                table: "Registration");

            migrationBuilder.DropIndex(
                name: "IX_Registration_ExamID",
                table: "Registration");

            migrationBuilder.AlterColumn<int>(
                name: "ExamID",
                table: "Registration",
                type: "INTEGER",
                nullable: false,
                oldClrType: typeof(Guid),
                oldType: "TEXT");

            migrationBuilder.AlterColumn<int>(
                name: "ID",
                table: "Registration",
                type: "INTEGER",
                nullable: false,
                oldClrType: typeof(Guid),
                oldType: "TEXT")
                .Annotation("Sqlite:Autoincrement", true);

            migrationBuilder.AddColumn<Guid>(
                name: "ExamID1",
                table: "Registration",
                type: "TEXT",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.AlterColumn<int>(
                name: "Registration2ID",
                table: "ExamRoomAllocation",
                type: "INTEGER",
                nullable: false,
                oldClrType: typeof(Guid),
                oldType: "TEXT");

            migrationBuilder.AlterColumn<int>(
                name: "Registration1ID",
                table: "ExamRoomAllocation",
                type: "INTEGER",
                nullable: false,
                oldClrType: typeof(Guid),
                oldType: "TEXT");

            migrationBuilder.CreateTable(
                name: "User",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "TEXT", nullable: false),
                    Avatar = table.Column<string>(type: "TEXT", nullable: false),
                    Password = table.Column<string>(type: "TEXT", nullable: false),
                    UserName = table.Column<string>(type: "TEXT", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_User", x => x.ID);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Registration_ExamID1",
                table: "Registration",
                column: "ExamID1");

            migrationBuilder.AddForeignKey(
                name: "FK_Registration_Exam_ExamID1",
                table: "Registration",
                column: "ExamID1",
                principalTable: "Exam",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
